﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace JsProxyStudy.Controllers
{
    public class JsProxyGeneratorController : Controller
    {
        //
        // GET: /JsProxyGenerator/

        public ActionResult Index()
        {
            // 元数据的获取可以采用反射，再利用 Attribute 提供个性化配置和扩展，此处省略。
            var metadata = new
            {
                Controller = "User",
                Actions = new[]
                {
                    new
                    {
                        Name = "Create",
                        Params = new []{ "username","password"}
                    }    
                }
            };

            return JavaScript(new Proxy { Metadata = metadata }.TransformText());
        }
    }
}
